package com.one.consumer.order.ui;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.one.common.config.RouterPath;
import com.one.common.utils.StringUtils;
import com.one.common.view.widget.InputLayout;
import com.one.common.view.widget.MyTitleBar;
import com.one.common.view.widget.StepView;
import com.one.consumer.BaseActivityC;
import com.one.consumer.R;
import com.one.consumer.reserve.model.item.CustomItem;
import com.one.consumer.reserve.presenter.CustomDetailPresenter;
import com.one.consumer.reserve.ui.view.DetailView;

import butterknife.BindView;

/**
 * author ：zhulunjun
 * email  ：zhulunjun@qq.com
 * date   ：2018/10/27 2:21 PM
 * description ：定制加配 详情
 **/
@Route(path = RouterPath.CU_ORDER_DETAIL)
public class CuOrderDetailActivity extends BaseActivityC<CustomDetailPresenter> implements DetailView<CustomItem> {
    @BindView(R.id.il_project_name)
    InputLayout ilProjectName;
    @BindView(R.id.il_huxing)
    InputLayout ilHuxing;
    @BindView(R.id.il_program_name)
    InputLayout ilProgramName;
    @BindView(R.id.il_price)
    InputLayout ilPrice;
    @BindView(R.id.il_contact)
    InputLayout ilContact;
    @BindView(R.id.il_phone)
    InputLayout ilPhone;
    @BindView(R.id.il_city)
    InputLayout ilCity;
    @BindView(R.id.il_address)
    InputLayout ilAddress;
    @BindView(R.id.sv_order)
    StepView svOrder;

    private String [] stepData = {"预约成功","线下确认","定金","进度款","尾款","完成"};

    @Override
    protected void initPresenter() {
        mPresenter = new CustomDetailPresenter(this, this);
    }

    @Override
    public int getLayoutResId() {
        return R.layout.activity_custom_detail;
    }

    @Override
    protected void initTitle() {
        super.initTitle();
        getMyTitleBar().setMode(MyTitleBar.Mode.BACK_TITLE)
                .setTitleText("加配订单详情");
    }

    @Override
    public void initView() {
        super.initView();
        svOrder.setData(stepData);
        svOrder.checkIndex(1);
    }

    @Override
    public void setDetail(CustomItem detail) {
        if (detail != null) {
            ilProjectName.setText(detail.getCustomized_name());
            ilHuxing.setText(detail.getHuxing_name());
            ilProgramName.setText(detail.getProgramme_name());
            ilContact.setText(detail.getContact_name());
            ilPhone.setText(detail.getContact_mobile());
            ilCity.setText(detail.getAddress());
            ilAddress.setText(detail.getAddress_detail());
            ilPrice.setText(detail.getOrder_price());
            ilPrice.getTvCenter().setTextColor(getResources().getColor(R.color.text_color_red_DA3924));

            int state = StringUtils.getIntToString(detail.getOrder_state());
            if(state>0) {
                svOrder.checkIndex(state-1);
            }
        }
    }

}
